package com.zrrd.yt.webll.controller;

import com.zrrd.yt.common.result.Result;
import com.zrrd.yt.item.client.ItemFeiginClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
public class WebItemController {
    @Autowired
    private ItemFeiginClient itemFeiginClient;

    //商品详情
    @GetMapping("/{skuId}.html")
    public String getItem(@PathVariable("skuId") Long skuId, Model model){
        //1.通过feign请求汇总服务获取数据
        Result<Map> result = itemFeiginClient.getItem(skuId);
        //2.将数据存入到model对象中
        model.addAllAttributes(result.getData());
        System.out.println("获取的汇总数据=====>"+result.getData());
        //3.转发请求 跳转页面
        return "/item/index";
    }
}
